package com.dkd.system.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.dkd.common.utils.DateUtils;
import com.dkd.system.domain.vo.Shebei;
import com.dkd.system.domain.vo.TbRegionDetailVo;
import com.dkd.system.mapper.TbEmpMapper;
import com.dkd.system.mapper.TbRegionMapper;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
//import com.dkd.system.mapper.TbRegionMapper;
import com.dkd.system.domain.TbRegion;
import com.dkd.system.service.ITbRegionService;

import javax.annotation.Resource;

/**
 * 区域Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-03-26
 */
@Service
public class TbRegionServiceImpl implements ITbRegionService 
{
    @Resource
    private TbRegionMapper tbRegionMapper;
@Resource
private TbEmpMapper tbEmpMapper;
    /**
     * 查询区域
     * 
     * @param id 区域主键
     * @return 区域
     */
    @Override
    public TbRegion selectTbRegionById(Long id)
    {
        return tbRegionMapper.selectTbRegionById(id);
    }

    /**
     * 查询区域列表
     * 
     * @param tbRegion 区域
     * @return 区域
     */
    @Override
    public List<TbRegion> selectTbRegionList(TbRegion tbRegion)
    {
        System.out.println(123);
        return tbRegionMapper.selectTbRegionList(tbRegion);
    }

    /**
     * 新增区域
     * 
     * @param tbRegion 区域
     * @return 结果
     */
    @Override
    public int insertTbRegion(TbRegion tbRegion)
    {
        tbRegion.setCreateTime(DateUtils.getNowDate());
        return tbRegionMapper.insertTbRegion(tbRegion);
    }

    /**
     * 修改区域
     * 
     * @param tbRegion 区域
     * @return 结果
     */
    @Override
    public int updateTbRegion(TbRegion tbRegion)
    {
        tbRegion.setUpdateTime(DateUtils.getNowDate());
        System.out.println(tbRegion.getRegionName()+"123");
        tbEmpMapper.updatereigion(tbRegion.getRegionName(),tbRegion.getId());
        return tbRegionMapper.updateTbRegion(tbRegion);
    }

    /**
     * 批量删除区域
     * 
     * @param ids 需要删除的区域主键
     * @return 结果
     */
    @Override
    public int deleteTbRegionByIds(Long[] ids)
    {
        return tbRegionMapper.deleteTbRegionByIds(ids);
    }

    /**
     * 删除区域信息
     * 
     * @param id 区域主键
     * @return 结果
     */
    @Override
    public int deleteTbRegionById(Long id)
    {
        return tbRegionMapper.deleteTbRegionById(id);
    }
    @Override
    public TbRegionDetailVo selectTbRegionById1(Long id){
        TbRegion tbRegion=tbRegionMapper.selectTbRegionById(id);
        TbRegionDetailVo tbRegionDetailVo=new TbRegionDetailVo();
        tbRegionDetailVo.setName(tbRegion.getRegionName());
        List<Shebei> list=tbRegionMapper.getsblist(id);
tbRegionDetailVo.setList(list);
return tbRegionDetailVo;
    }
}
